package vn.demand.dragon.controller
{
	import com.salesbuilder.control.TabManager;
	
	import mx.core.Container;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	
	import vn.demand.dragon.model.ProjectItemProxy;
	import vn.demand.dragon.view.ProjectFilesScreenMediator;
	import vn.demand.dragon.view.ProjectFormMediator;
	import vn.demand.dragon.view.ProjectItemScreenMediator;
	import vn.demand.dragon.view.ProjectPanelMediator;
	import vn.demand.dragon.view.TaskScreenMediator;
	
	public class CloseProjectPanelCommand extends SimpleCommand
	{
		override public function execute( note:INotification ) :void    
		{
			RIALogger.debug(this, "CloseProjectPanelCommand::execute");
			var projectVO:Object = note.getBody();
			var panelId:String = ProjectPanelMediator.makeId(projectVO);
			var m:ProjectPanelMediator = facade.retrieveMediator(panelId) as ProjectPanelMediator;
			if (null == m) return;
			var tab:Container = m.panel as Container;
			if (tab == null) return;
			var lineId:String = TaskScreenMediator.makeId(projectVO);
			var pitemId:String = ProjectItemScreenMediator.makeId(projectVO);
			facade.removeMediator(panelId);
			facade.removeMediator(ProjectFormMediator.makeId(projectVO));
			facade.removeMediator(ProjectItemScreenMediator.makeId(projectVO));
			facade.removeMediator(ProjectFilesScreenMediator.makeId(projectVO));
			facade.removeProxy(ProjectItemProxy.makeId(projectVO));
			facade.removeProxy(ProjectFilesScreenMediator.makeId(projectVO));
			TabManager.removeTab(tab);
        }
	}
}